home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / update~4.z / update~4 / lib_stdio_fopen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-06  |  826 b   |  35 lines

  1. /*            f o p e n
  2.  *
  3.  * Open a stream and associate it with the named file. The name
  4.  * of the file is passed as a character string. The type of
  5.  * stream is passed as a string with the first character indicating
  6.  * the mode with which the file is to be opened.
  7.  *
  8.  * The function returns a pointer to the stream if successful
  9.  * otherwise it returns NULL.
  10.  *
  11.  * Patchlevel 1.0
  12.  *
  13.  * Edit History:
  14.  */
  15.  
  16. #include "stdiolib.h"
  17.  
  18. /*LINTLIBRARY*/
  19.  
  20. FILE *fopen(name, mode)
  21.  
  22. CONST char *name;                /* name of file */
  23. CONST char *mode;                /* mode to open */
  24.  
  25. {
  26.   FILE **sp;                /* slot in table */
  27.   int fd;                /* opened file descriptor */
  28.   short flags;                /* flag settings */
  29.  
  30.   return (sp = _slot((FILE *) NULL)) == NULL ||
  31.          (fd = _fopen(name, mode, -1, &flags)) == -1
  32.     ? NULL
  33.     : (*sp = _file((FILE *) NULL, fd, flags));
  34. }
  35.